/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ysw.action;

import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import ysw.jdbc.MealJdbc;
import ysw.vo.Meal;

/**
 *
 * @author Administrator
 */
public class MealAction extends ActionSupport{
    private Meal meal;

    public Meal getMeal() {
        return meal;
    }

    public void setMeal(Meal meal) {
        this.meal = meal;
    }
    private List<Meal> mealList;
    public String execute() throws Exception{
        MealJdbc mealJ=new MealJdbc();
        meal.setMealid(meal.getMealid());
       meal.setMealtype(meal.getMealtype());
       meal.setMealcost(meal.getMealcost());
        mealJ.addMeal(meal);
        return SUCCESS;
    }

public String showAllMeal() throws Exception{
     Meal meal=new Meal();
     MealJdbc mealJ=new MealJdbc();
     
        try{
            mealList=mealJ.showMeal();
        }catch(SQLException e){
            e.printStackTrace();
        }
     
	Map request=(Map)ActionContext.getContext().get("request");
        request.put("mealList",mealList);
        return SUCCESS;
    }
}
